import React from 'react';
import { observer, inject } from 'mobx-react';
import WeaSystemField from '../../public/wf-system-field/index';
import * as Util from '../../util/formUtil';
import * as FieldUtil from '../../util/public/fieldUtil';

@inject('globalStore', 'layoutStore')
@observer
export default class SystemElement extends React.Component{
    doChangeEvent = (value) => {
        const { globalStore,layoutStore,fieldMark,islsx } = this.props;
        layoutStore.changeSingleFieldValue(fieldMark, {value: value});
        if(fieldMark == 'field-10') {//密级字段改变时，修改表单的当前密级，用于创建节点联动
            globalStore.setSecLevelInfo({secLevel : value});
        }else if(islsx){
            if(value=='<p>&nbsp;&nbsp;&nbsp;&nbsp;</p>\n'||value=='<p>&nbsp;&nbsp;&nbsp;&nbsp;</p>'){
                value='';
            }
            globalStore.markInfo.remark=value;
            wfform.getGlobalStore().markInfo.remarkInfo.remark=value;
        }
        
	}
    render() {
        const { globalStore,layoutStore,fieldMark,fieldAttr,symbol,fieldObj } = this.props;
        let { baseProps,islsx=false } = this.props;
        const { commonParam,markInfo,secLevelInfo } = globalStore;
        const {containSignInput} = layoutStore;
        const { requestType } = commonParam;
        baseProps.fieldName  = FieldUtil.convertSystemFieldName(fieldMark);
        baseProps.specialobj = fieldObj.specialobj || [];

        return (
            <WeaSystemField ecId={`${this && this.props && this.props.ecId || ''}_WeaSystemField@tuxsa6`} 
                requestType={requestType}
                markInfo={markInfo}
                secLevelInfo={secLevelInfo}
                containSignInput = {containSignInput}
                onChange={this.doChangeEvent}
                islsx={islsx}
                {...baseProps}
            />
        )
    }
}